package collection;

import java.util.ArrayList;
import java.util.Collection;

/**
 * 集合只能存放引用类型元素，并且存放的是元素的引用地址
 */
public class CollectionDemo4 {
    public static void main(String[] args) {
        Collection c = new ArrayList();
        Point p = new Point(1,2);
        c.add(p);//将p的值存入了集合，而p是引用类型变量,存的值是地址
        System.out.println("p:"+p);
        System.out.println("c:"+c);
        p.setX(2);
        System.out.println("p:"+p);
        System.out.println("c:"+c);
    }
}








